<style>
  .picImg {
    width: 40px;
    height: 40px;
  }
</style>
<template>
  <div class="app-container">
    <el-table v-loading="listLoading" :data="list" element-loading-text="正在查询中。。。" border fit highlight-current-row>

      <el-table-column align="center" min-width="100" label="保险公司ID" prop="insuranceID"/>
      <el-table-column align="center" min-width="100" label="保代公司/权益服务商ID" prop="agentID"/>
      <el-table-column align="center" min-width="100" label="保理公司ID" prop="factoringID"/>
      <el-table-column align="center" min-width="100" label="共管账户号" prop="account"/>
      <el-table-column align="center" min-width="100" label="共管账户名称" prop="accName"/>
      <el-table-column align="center" min-width="100" label="共管账户银行代码" prop="bankCode"/>
      <el-table-column align="center" min-width="100" label="共管账户联行号" prop="interBankNo"/>
      <el-table-column align="center" label="操作" width="250" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button type="primary" size="mini"
                     @click="balance(scope.row)">余额查询
          </el-button>
          <el-button type="danger" size="mini"
                     @click="water(scope.row)">流水查询
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize"
                @pagination="getList"/>
    <el-dialog :visible.sync="editDialogVisible" title="流水明细">
      <el-table v-loading="listLoading1" :data="list1" element-loading-text="正在查询中。。。" border fit highlight-current-row>

        <el-table-column align="center" min-width="100" label="操作时间" prop="opTime"/>
        <el-table-column align="center" min-width="100" label="操作类型" prop="opType"/>
        <el-table-column align="center" min-width="100" label="收入/支出" prop="sideType"/>
        <el-table-column align="center" min-width="100" label="发生金额" prop="amount"/>
        <el-table-column align="center" min-width="100" label="对方账户" prop="sideAccount"/>
        <el-table-column align="center" min-width="100" label="对方账户名称" prop="sideName"/>
        <el-table-column align="center" min-width="100" label="对方银行" prop="sideBank"/>
        <el-table-column align="center" min-width="100" label="备注" prop="remark"/>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="editDialogVisible = false">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {doGet, doPost} from '@/api'
  import {cities} from '@/utils/base'
  import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
//  import fileUp from '@/components/fileUp' // Secondary package based on el-pagination

  const FETCH_PAGE = 'accsearch.html'
  const FETCH_URL = {
    LIST: `${FETCH_PAGE}?op=acclist`,
    CREATE: `${FETCH_PAGE}?op=list`,
  }
  export default {
    name: 'accsearch',
    components: {Pagination},
    filters: {},
    data() {
      return {
        list: [],
        list1: [],
        total: 0,
        listLoading: true,
        listLoading1:true,
        listQuery: {
//                    page: 1,
//                    pageSize: 20
        },
        dialogStatus: undefined,
        textMap: {
          update: '余额查询',
          create: '流水查询'
        },
        editDialogVisible: false,
      }
    },
    created() {
      this.getList()
    },
    methods: {
      getList() {
        this.listLoading = true
        doGet(FETCH_URL.LIST, this.listQuery).then(response => {
          this.list = response.rows
          this.total = response.rows.length
          this.listLoading = false
        }).catch(() => {
          this.list = []
          this.total = 0
          this.listLoading = false
        })
      },
      balance(row) {
        console.log(row)
      },
      water(row) {
        this.editDialogVisible=true
        console.log(row)
        var senJSON = {}
//        senJSON.startTime = row.startTime
//        senJSON.endTime = row.endTime
        senJSON.account = row.account
        this.listLoading1 = true
        doGet(FETCH_URL.CREATE, senJSON).then(response => {
          this.list1 = response.rows
          this.listLoading1 = false
        }).catch(() => {
//          this.list = []
          this.listLoading1 = false
        })
      },
    }
  }
</script>
